
# 1. 实现登录函数
def login(username,password):
    db_username = 'admin'
    db_password = '123456'

    # 判断用户名是否为空
    if username is None or username == "":
        return {"code":1,"message":"用户名不能为空!"}
    # 判断密码是否为空
    if password is None or password == "":
        return {"code":2,"message":"密码不能为空"}

    # 用户名和密码是否和数据库中的匹配
    if username == db_username and password == db_password:
        return {"code":0,"message":"登录成功"}

    # 登录失败
    return {"code":3,"message":"用户名或密码不正确!"}